home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 5.8 KB | 142 lines | [TEXT/MPS ] |
- // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
- // UDrawShapes.h
-
- // This sample application illustrates numerous features of MacApp and the
- // Printing building block.
-
- /*-----------------------------------------------------------------------------
- The application's windows show a palette at left, and a drawing area to the
- right; this is similar to MacDraw and MacPaint.
-
- In the windows, the user can draw quadrilaterals and ovals (choosing which
- from the palette) and can move already-drawn shapes around.
-
- Command-D is used to toggle the availability of a special 'More Debug' menu
- in the menu bar, both to illustrate how to have commands on command-keys that
- aren't themselves in the menu and how to insert and delete menus dynamically.
- Three special debugging commands are only available when this special menu
- is inserted.
-
- Full Clipboard support is also illustrated, including most features that any
- application would be likely to need. Shapes can be cut or pasted between
- documents, and picture-versions of shapes on the Clipboard can be pasted into
- other applications such as MacPaint.
-
- Printing and Filing are also supported. Window state is preserved in saved
- files. Filing uses both data and resource forks, to illustrate both
- techniques.
-
- All commands are undoable. Commands illustrated include commands to Draw,
- commands to move objects around within the view, and commands to change
- properties of objects.
-
- Hold the OPTION key down while drawing to constrain the drawing to be a
- square/circle rather than a general rectangle/oval while sketching. This
- constrains the object being drawn to be a square/circle whose side/diameter
- is a horizontal or vertical offset of the mouse from the anchor point,
- whichever is SMALLER. This may feel a bit strange in practice, but it does
- illustrate a feature.
- -----------------------------------------------------------------------------*/
-
- #ifndef __UDRAWSHAPES__
- #define __UDRAWSHAPES__
-
- #ifndef __UAPPLICATION__
- #include <UApplication.h>
- #endif
-
- #ifndef __USHAPELIST__
- #include "UShapeList.h"
- #endif
-
- //--------------------------------------------------------------------------------------------------
-
- class TPatternsMenu;
- class TToolsMenu;
- class TToolsPalette;
-
- //--------------------------------------------------------------------------------------------------
- // Constants
-
- const unsigned long kSignature = 'SS05'; // application signature
- const unsigned long kDocType = 'SF05'; // File type for document files
- // created by this application
- const unsigned long kTextFileType = 'TEXT';
- const unsigned long kScrapType = kTextFileType;
- const unsigned long kShapeClipType = 'SHAP'; // Clipboard type for my shapes
-
- //--------------------------------------------------------------------------------------------------
- // Commands
- const CommandNumber cPatterns = 1300; // Used to enable the Patterns tear-off menu
- //const CommandNumber cPatternsMax = cPatterns + kTotalPatterns;
-
- const CommandNumber cPickColor = 1005; // Use Color Picker for shape's color
-
- const CommandNumber cNewShape = 1010; // Drawing a new shape
- const CommandNumber cMoveShape = 1011; // Moving one or more shapes
-
- const CommandNumber cChangeShade = 1012; // Buzz command for "Undo Shade Change"
- const CommandNumber cChangeColor = 1013; // Buzz command for "Undo Color Change"
- const CommandNumber cChangeTool = 1014; // Buzz command for "Undo Tool Change"
-
- const CommandNumber cToggleMoreDebugMenu = 1200; // Command to put up the "More Debug" menu,
- // or, if it is already up, to take it down.
- // This demonstrates both how to handle commands
- // not in the menu bar and how to put entire
- // menus up and take them down dynamically.
-
- // The following four commands are only available in the "More Debug" menu,
- // which is only accessible if you type Command-D to insert that menu into the menu bar.
-
- const CommandNumber cPasteReplacesSelection = 118; // Debugging: whether pasting into a
- // shapeView should supplant any existing
- // selection or not. If not, the pastee instead
- // is centered in the window.
- const CommandNumber cRecalcExtent = 119; // Debugging: performs immediate recomputation
- // of view extent; if gConstrainDrags is false,
- // it is possible for a shape to be beyond the
- // view border; the view's extent can be refigured
- // on demand by using this command
- const CommandNumber cConstrainDrags = 120; // Debugging: whether shape-dragging should be
- // constrained so that the entire selection fits
- // within the view or not.
- const CommandNumber cBetterFeedback = 121; // Debugging: whether to use the code which
- // provides better TrackFeedback
-
- //--------------------------------------------------------------------------------------------------
- // TShapeApplication
- //--------------------------------------------------------------------------------------------------
- class TShapeApplication : public TApplication
- {
- MA_DECLARE_CLASS;
-
- public:
- TShapeApplication(); // Constructor
-
- void IShapeApplication();
- // Initialize the Application
-
- virtual TDocument *DoMakeDocument(CommandNumber itsCommandNumber, TFile* itsFile);
- // Creates a TShapeDocument
-
- #if qDebug
- virtual void DoCommandKeyEvent(TToolboxEvent* event); // Override
- virtual void DoMenuCommand(CommandNumber aCommandNumber); // Override
- virtual void DoSetupMenus(); // Override
- #endif
-
- virtual TView* MakeViewForAlienClipboard(); // Override
- };
-
- //--------------------------------------------------------------------------------------------------
- // extern Globals
-
- // extern TShapeApplication* gShapeApplication;
- extern Boolean gPasteReplacesSelection;
- extern Boolean gConstrainDrags;
- extern short gStaggerCount; // for SimpleStagger
- extern CCrsrHandle gRainbowArrow;
- extern Boolean gBetterFeedback;
-
- #endif
-